package org.theonept.gwt.chart.widget;

import org.theonept.gwt.svg.widget.CircleSVG;
import org.theonept.gwt.svg.widget.LineSVG;
import org.theonept.gwt.svg.widget.PathSVG;
import org.theonept.gwt.svg.widget.SVGDocument;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;

public class Chart extends Widget implements HasClickHandlers {

	public Chart(Integer height, Integer width) {

		SVGDocument svgDocument = new SVGDocument(height, width);
		svgDocument.add(new LineSVG(0, height - 10, width, height - 10));
		svgDocument.add(new LineSVG(10, height, 10, 0));
		svgDocument.add(new PathSVG().setMove(10, 250).setLine(50, 200)
				.setLine(90, 280).setLine(140, 100).execute());
		svgDocument.add(new CircleSVG(10, 250, 3));
		svgDocument.add(new CircleSVG(50, 200, 3));
		svgDocument.add(new CircleSVG(90, 280, 3));
		svgDocument.add(new CircleSVG(140, 100, 3));
		setElement(svgDocument.getElement());

	}

	@Override
	public HandlerRegistration addClickHandler(ClickHandler handler) {
		return addDomHandler(handler, ClickEvent.getType());
	}

}
